package com.tanhua.admin.controller;

import com.itheima.tanhua.vo.AnalysisSummaryVo;
import com.tanhua.admin.service.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Lff
 * @date 2022/4/7
 */
@RestController
@RequestMapping("/dashboard")
public class DashboardController {
    @Autowired
    private DashboardService dashboardService;

    /**
     * 新增、活跃用户、次日留存率
     *
     * @return
     */
    @GetMapping("/users")
    public ResponseEntity users(Long sd, Long ed, String type) {
        Map resultMap = dashboardService.dashboard(sd, ed, type);
        return ResponseEntity.ok(resultMap);
    }

    /**
     * 概要统计信息
     *
     * @return
     */
    @GetMapping("/summary")
    public ResponseEntity summary() {
        AnalysisSummaryVo result = dashboardService.summary();
        return ResponseEntity.ok(result);
    }
}
